package com.holly.common_view.utils;

import android.content.Context;
import android.widget.Toast;
/**
 * Toast
 *
 * @author Joey Huang（QQ:273179370）
 * @created 2016/6/10
 */
public class T {
    private static boolean isShow = true;
    private static Toast mToast;

    private T() {
        throw new UnsupportedOperationException("cannot be instantiated");
    }

    public static void showShort(Context context, String text) {
        if (isShow) {
            if (mToast == null) {
                mToast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
            } else {
                mToast.setText(text);
                mToast.setDuration(Toast.LENGTH_SHORT);
            }
            mToast.show();
        }
    }

    public static void showLong(Context context, String text) {
        if (isShow) {
            if (mToast == null) {
                mToast = Toast.makeText(context, text, Toast.LENGTH_LONG);
            } else {
                mToast.setText(text);
                mToast.setDuration(Toast.LENGTH_LONG);
            }
            mToast.show();
        }
    }

    public static void showShort(Context context, int resId) {
        if (isShow) {
            if (mToast == null) {
                mToast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
            } else {
                mToast.setText(resId);
                mToast.setDuration(Toast.LENGTH_SHORT);
            }
            mToast.show();
        }
    }
}
